<template>
	<view hover-class="">
			<cust bgColor="bg-gradual-blue" :isBack="true">
				<block slot="backText">返回</block>
				<block slot="content">辉哥餐饮</block>
				<block slot="right">后台设置</block>
			</cust>
			<!-- <navigator style="font-size: 1999rpx;" url="../foot/opeartion">gogogogo</navigator> -->
			<view>
				<foot :ll="bl"></foot>
				
				<foot_current :cl="cl" ></foot_current>
				
			</view>

	</view>
</template>

<script>
	import cust from '../../components/cu-custom.vue';
	import foot_current from '../../components/current_foot.vue';
	import foot from '../../components/foot.vue';
	import * as footUtil from 'js/foot.js';
	import * as util from 'js/utils.js';
	export default {
		data() {
			return {
				bl: [],
				cl: {},
				modalName: null,
				listTouchStart: 0,
				listTouchDirection: null,
				ColorList: this.ColorList,
			}
		},
		onLoad() {
			
		},
		onReady() {
		},
		methods: {
			getCurrentData: function() {
				this.$data.cl = footUtil.currentRecord();
			},
			scrolltoupper: function(e){
				console.log("滚动了")
				console.log(e)
			},
			// ListTouch触摸开始
			ListTouchStart(e) {
				this.listTouchStart = e.touches[0].pageX
			},
			
			// ListTouch计算方向
			ListTouchMove(e) {
				this.listTouchDirection = e.touches[0].pageX - this.listTouchStart > 0 ? 'right' : 'left'
			},
			
			// ListTouch计算滚动
			ListTouchEnd(e) {
				if (this.listTouchDirection == 'left') {
					this.modalName = e.currentTarget.dataset.target
				} else {
					this.modalName = null
				}
				this.listTouchDirection = null
			},
		},
		components:{
			"foot_current" : foot_current,
			"foot" : foot,
			"cust" : cust,
		},
		mounted() {
			
			
			var receiver;  
			
			                receiver = plus.android.implements('com.iflytek.cloud.SynthesizerListener', {  
			                    onEvent: function( eventType,  arg1,  arg2,  obj) {  
			                        console.log("onEvent");  
			                    },  
			                    onSpeakBegin: function() {  
			                        console.log("开始阅读");  
			                    },  
			                    onSpeakPaused: function() {  
			                        console.log(" 暂停播放 ");  
			                    },  
			                    onSpeakResumed: function() {  
			                        console.log("继续播放");  
			                    },  
			                    onBufferProgress: function(percent, beginPos, endPos, info) {  
			                        console.log("合成进度" + percent);  
			                    },  
			                    onSpeakProgress: function(percent, beginPos, endPos) {  
			                        console.log("播放进度" + percent);  
			                    },  
			                    onCompleted: function(error) {  
			                        console.log("播放完毕");  
			                    }  
			                });  
			
			                var main = plus.android.runtimeMainActivity();  
			
			                var SpeechUtility = plus.android.importClass('com.iflytek.cloud.SpeechUtility');  
			
			                SpeechUtility.createUtility(main, "appid=53feacdd");  
			
			                var SynthesizerPlayer = plus.android.importClass('com.iflytek.cloud.SpeechSynthesizer');  
			
			                var play = SynthesizerPlayer.createSynthesizer(main, undefined);  
			                 // 开始合成  
			                
			        
			
			let _this = this;
			this.getCurrentData();
			let speek = "铛铛铛铛  "+new Date().getFullYear() + "年" + (new Date().getMonth()+1)+"月" + (new Date().getDate()) +"日" + (new Date().getHours()) + "点" + (new Date().getMinutes()) +"分  辉哥为您播报今天的饭菜！"  +"   今天 上午的饭是 ";
			
			for( let [k,v] of this.$data.cl.mid.entries())
			{
				speek+=(v?v.name:"")+" ";
			}
			speek+="下午的饭是 ";
			for( let [k,v] of this.$data.cl.lat.entries())
			{
				speek+=(v?v.name:"")+" ";
			}
			
			
			play.startSpeaking(speek, receiver); 
			console.log(speek);
			if(plus.fingerprint) {
					if(!plus.fingerprint.isSupport()) {
						console.log('此设备不支持指纹识别');
						return;
					}
					if(!plus.fingerprint.isKeyguardSecure()) {
						console.log('此设备未设置密码锁屏，无法使用指纹识别');
						return;
					}
					if(!plus.fingerprint.isEnrolledFingerprints()) {
						console.log('此设备未录入指纹，请到设置中开启');
						return;
					}
					console.log('此设备支持指纹识别');
					
					plus.fingerprint.authenticate(function(){
							plus.nativeUI.closeWaiting();//兼容Android平台关闭等待框
							console.log('指纹识别成功');
							_this.$data.bl = footUtil.showHistory();
							console.log(_this.$data.bl)
							for(let [k,v] of _this.$data.bl.entries())
							{
								console.log(k,v);
							}
						}, function(e){
							switch(e.code) {
							case e.AUTHENTICATE_MISMATCH:
							plus.nativeUI.toast('不是本人，无法查看历史记录 ，请重新输入');
							break;
							case e.AUTHENTICATE_OVERLIMIT:
							plus.nativeUI.closeWaiting();//兼容Android平台关闭等待框
							plus.nativeUI.alert('确认不是本人，请速速将手机送至本人手中');
							break;
							default:
							plus.nativeUI.closeWaiting();//兼容Android平台关闭等待框
							plus.nativeUI.alert('系统错乱，赶紧爬，别烦老子');
							break;
							}
						});
				}else {
					console.log('当前环境不支持指纹识别API，请更新到最新版本');
				}
		},
	}
</script>

<style>
	page {
		background-color: #ffffff;
		width: 100%;
	}
	
	
</style>
